package com.yuda.tools.miscellaneous.mapper;

import com.yuda.tools.miscellaneous.dto.City;
import com.yuda.tools.miscellaneous.dto.School;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SpartaThreeMapper {

    //添加自缴费学校
    @Update("update sparta_school set show_status =#{status} where id = #{schoolId}")
    public void updateSchool(@Param("status") int status, @Param("schoolId") Long schoolId);

    @Update("update sparta_province set  status =#{status} where id = #{provinceId}")
    public void updateProvince(@Param("status") int status, @Param("provinceId") Long provinceId);

    @Update("update sparta_city set  status =#{status} where id = #{cityId}")
    public void updateCity(@Param("status") int status, @Param("cityId") Long cityId);


    @Select("select id as cityId,`name` from sparta_city where parent_id = #{provinceId}")
    List<City> listCityByProvinceId(Long provinceId);


    @Select("select id as schoolId,`name` from sparta_school where city_id = #{cityId}")
    List<School> listSchoolByCityId(Long cityId);

    @Select("select count(1) from sparta_school where show_status =1 and city_id = #{cityId}")
    int countStatusEq1(String cityId);
}
